﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeBehind="Category.aspx.cs" Inherits="ecommerceSample.CategoryPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
                    ConnectionString="<%$ ConnectionStrings:ecommerceSample %>" 
                    ProviderName="<%$ ConnectionStrings:ecommerceSample.ProviderName %>"             
                    SelectCommand="SELECT * FROM Articles INNER JOIN Categories ON Articles.CategoryId = Categories.CategoryId INNER JOIN aspnet_Users ON Articles.UserId = aspnet_Users.UserId WHERE Articles.CategoryId=@id  ORDER BY Date DESC ">
                     <SelectParameters>
                        <asp:QueryStringParameter Name="id" QueryStringField="id" />
                    </SelectParameters>
                </asp:SqlDataSource>                  
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="ArticleId" DataSourceID="SqlDataSource2" PageSize="10" BorderWidth="0px" >
                    <Columns>
                        <asp:TemplateField ItemStyle-BorderWidth="0px" HeaderStyle-BorderWidth="0px">
                            <HeaderTemplate>
                                <div class="article-category">Artículos Recientes</div>
                            </HeaderTemplate>
                            <ItemTemplate>
                            <asp:Table ID="Table1" runat="server">
                                    <asp:TableRow ID="TableRow1" runat="server">
                                        <asp:TableCell ID="TableCell1" runat="server" >
                                            <img class="small-images" alt="image" src="<%# Eval("Image") %>" width="120px"/>
                                        </asp:TableCell>
                                        <asp:TableCell ID="TableCell2" runat="server" CssClass="text-content">                                            
                                            <hr />
                                            <div class="article-grey"><a href="/Category.aspx?id=<%# Eval("CategoryId") %>"><%# Eval("Name") %></a><small>: <%# Eval("Date") %></small></div>
                                                <b>
                                                <div class="article-title"><big><a href="/User/Article.aspx?id=<%# Eval("ArticleId") %>"><%# Eval("Title") %></a></big></div>
                                                </b>
                                            <small>
                                                <div class="article-grey">Posteado por: <big><a href="/User/User.aspx?id=<%# Eval("UserId") %>"><%# Eval("UserName") %></a></big></div>
                                                <%# LimitWords(Eval("Text").ToString(),50)%>                                            
                                                <a href="/User/Article.aspx?id=<%# Eval("ArticleId") %>"><br />
                                                <div class="read-more"><i>leer más</i></a></div>
                                            </small>
                                        </asp:TableCell>
                                    </asp:TableRow>
                                </asp:Table>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"/>
                    <PagerStyle HorizontalAlign="Center" VerticalAlign="Top" BorderColor="White"/>
                </asp:GridView>         
</asp:Content>